#pragma once 

namespace Collision {
	inline bool pointInRect(glm::ivec2 point, glm::dvec4 rect) {
		return	point.x >= rect[0] && point.x <= rect[2] &&
				point.y >= rect[1] && point.y <= rect[3];
	}

	inline bool SphereSphere(glm::vec3 c0, float r0, glm::vec3 c1, float r1) {
		return (glm::length(c0 - c1) <= (r0+r1));
	}
}

class CollisionSphere;

class CollGeom {
public:
	CollGeom() : 
		pos(0,0,0) 
	{}

	virtual bool intersects(CollGeom* other) = 0;
	virtual bool intersects(CollisionSphere* sphere) = 0;

	glm::vec3 pos;
};


class CollisionSphere : public CollGeom {
public:
	CollisionSphere(const glm::vec3 & pos, float radius) 
		: radius(radius)
	{ this->pos = pos; }
	
	virtual bool intersects(CollGeom* other) {
		return other->intersects(this);
	}
	virtual bool intersects(CollisionSphere* sphere) {
		return glm::length(pos - sphere->pos) <= (radius + sphere->radius);
	}

	float radius;
};


